#include "sfsis.h"
#include "debug.h"

/*当新增寄存器时，可以在这里进行doAction操作，请注意！！！这里的操作不可以是功能性操作，仅是对寄存器和配置功能性无关操作*/
SF_Boolen config_shadowResetAction(void)
{
    SF_Boolen ret = SF_True;
    /*doModeWrite = 0xaa 时，刷新mode区域的内容到nv中*/
    if (gCfgCommonPtr->doModeWrite == 0xAA)
    {
        DPRINT(DEBUG_INFO, "[CONFIG] Flusing Mode to NoneVolitale Memory.\r\n");
        gCfgCommonPtr->doModeWrite = 0;
        if (gCfgModePtr->mode < CONFIG_MODE_MAX_NV_USED)
        {
            hwl_iic_write(CONFIG_MAP_MODE_HEAD, (su8 *)gCfgModePtr, sizeof(Config_Mode));
            gCfgCommonPtr->doModeWrite = gSCfg_u.entity.common.entity.doModeWrite; //恢复默认值
        }
        else
        {
            DPRINT(DEBUG_INFO, "[CONFIG] Big than CONFIG_MODE_MAX_NV_USED, please check the config.\r\n");
            ret = SF_False;
        }
    }
    /*doModeFactoryWrite = 0xaa 时，刷新ModeFactory区域的内容到nv中*/
    else if (gCfgCommonPtr->doModeFactoryWrite == 0xAA)
    {
        DPRINT(DEBUG_INFO, "[CONFIG] Flusing ModeFactory to NoneVolitale Memory.\r\n");
        gCfgCommonPtr->doModeFactoryWrite = 0;
        hwl_iic_write(CONFIG_MAP_MODEFACTORY_HEAD, (su8 *)gCfgModeFactoryPtr, sizeof(Config_ModeFactory));
        gCfgCommonPtr->doModeFactoryWrite = gSCfg_u.entity.common.entity.doModeFactoryWrite; //恢复默认值
    }
    /*doFactoryWrite = 0xaa 时，刷新Factory区域的内容到nv中*/
    else if (gCfgCommonPtr->doFactoryWrite == 0xAA)
    {
        DPRINT(DEBUG_INFO, "[CONFIG] Flusing Factory to NoneVolitale Memory.\r\n");
        gCfgCommonPtr->doFactoryWrite = 0;
        hwl_iic_write(CONFIG_MAP_FACTORY_HEAD, (su8 *)gCfgFactoryPtr, sizeof(Config_Factory));
        gCfgCommonPtr->doFactoryWrite = gSCfg_u.entity.common.entity.doFactoryWrite; //恢复默认值
    }
    return ret;
}
